<?php

/**
 * This is the model class for table "trazadoras.embarazo".
 *
 * The followings are the available columns in table 'trazadoras.embarazo':
 * @property integer $id
 * @property integer $id_beneficiario
 * @property integer $id_prestacion
 * @property integer $id_tipotrazadora
 * @property string $fecha_control
 * @property string $semanas_gestacion
 * @property string $fum
 * @property string $fpp
 * @property string $fpcp
 * @property string $peso
 * @property string $ta_baja
 * @property string $ta_alta
 * @property string $antitetanica
 * @property string $vdrl
 * @property string $es_control
 * @property string $fecha_carga
 * @property string $clave_beneficiario
 *
 * The followings are the available model relations:
 * @property TipoTrazadora $id
 */
class Embarazo extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'trazadoras.embarazo';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_beneficiario, id_prestacion, id_tipotrazadora, fecha_control, semanas_gestacion, peso, ta_baja, ta_alta, fecha_carga', 'required'),
			array('id_beneficiario, id_prestacion, id_tipotrazadora', 'numerical', 'integerOnly'=>true),
			array('semanas_gestacion', 'length', 'max'=>6),
			array('peso', 'length', 'max'=>7),
			array('ta_baja, ta_alta', 'length', 'max'=>5),
			array('antitetanica, vdrl, es_control', 'length', 'max'=>1),
			array('fum, fpp, fpcp, clave_beneficiario', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, id_beneficiario, id_prestacion, id_tipotrazadora, fecha_control, semanas_gestacion, fum, fpp, fpcp, peso, ta_baja, ta_alta, antitetanica, vdrl, es_control, fecha_carga, clave_beneficiario', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'id' => array(self::BELONGS_TO, 'TipoTrazadora', 'id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'id_beneficiario' => 'Id Beneficiario',
			'id_prestacion' => 'Id Prestacion',
			'id_tipotrazadora' => 'Id Tipotrazadora',
			'fecha_control' => 'Fecha Control',
			'semanas_gestacion' => 'Semanas Gestacion',
			'fum' => 'Fum',
			'fpp' => 'Fpp',
			'fpcp' => 'Fpcp',
			'peso' => 'Peso',
			'ta_baja' => 'Ta Baja',
			'ta_alta' => 'Ta Alta',
			'antitetanica' => 'Antitetanica',
			'vdrl' => 'Vdrl',
			'es_control' => 'Es Control',
			'fecha_carga' => 'Fecha Carga',
			'clave_beneficiario' => 'Clave Beneficiario',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('id_beneficiario',$this->id_beneficiario);
		$criteria->compare('id_prestacion',$this->id_prestacion);
		$criteria->compare('id_tipotrazadora',$this->id_tipotrazadora);
		$criteria->compare('fecha_control',$this->fecha_control,true);
		$criteria->compare('semanas_gestacion',$this->semanas_gestacion,true);
		$criteria->compare('fum',$this->fum,true);
		$criteria->compare('fpp',$this->fpp,true);
		$criteria->compare('fpcp',$this->fpcp,true);
		$criteria->compare('peso',$this->peso,true);
		$criteria->compare('ta_baja',$this->ta_baja,true);
		$criteria->compare('ta_alta',$this->ta_alta,true);
		$criteria->compare('antitetanica',$this->antitetanica,true);
		$criteria->compare('vdrl',$this->vdrl,true);
		$criteria->compare('es_control',$this->es_control,true);
		$criteria->compare('fecha_carga',$this->fecha_carga,true);
		$criteria->compare('clave_beneficiario',$this->clave_beneficiario,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Embarazo the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
